package com.atguigu.gmall.file;

import java.util.concurrent.*;

/**
 * @Author: 李旭
 * @Time: 14:40
 * @Description:
 *
 *     异步编排
 *       多线程 核心实现类   多线程复杂交互
 */
public class CompletableFutureDemo {


    public static void main(String[] args) throws Exception{
      /*  Thread thread = new Thread(new MyRunable(),"AA");
        thread.start();*/
    /*    MyThread myThread = new MyThread();
        myThread.start();*/

        //中间人
  /*      FutureTask futureTask = new FutureTask(new MyCallable());
        Thread thread = new Thread(futureTask,"AA");
        thread.start();*/
        //System.out.println(futureTask.get());

        ThreadPoolExecutor threadPoolExecutor = new
                ThreadPoolExecutor(5,10,1, TimeUnit.MINUTES,
                new ArrayBlockingQueue<>(10));

        threadPoolExecutor.execute(() -> {
            System.out.println(Thread.currentThread().getName());
        });
        System.out.println(Thread.currentThread().getName());
    }
}
class MyCallable implements Callable{

    @Override
    public Object call() throws Exception {
        System.out.println(Thread.currentThread().getName());
        return "hahah";
    }
}
class MyThread extends Thread{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }

}
class MyRunable implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}
